/*
 * @Date: 2023-03-09 13:33:07
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-03-09 13:39:21
 * @FilePath: \A19\backend\src\api\Get\ApiGetCourseTest.ts
 */
import { ApiCall } from "tsrpc";
import { ReqGetCourseTest, ResGetCourseTest } from "../../shared/protocols/Get/PtlGetCourseTest";
import { Global } from '../../Global/index';

export default async function (call: ApiCall<ReqGetCourseTest, ResGetCourseTest>) {
    // TODO
    const user = call.currentUser
    const examOrHomework = call.req.examOrHomework

    const ret = await Global.collection(examOrHomework === 'exam'?'tests':'homework').find({
        course:call.req.course
    }).toArray()

    call.succ({
        tests:ret
    })
}